﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Things.Common;
using LTP.Accounts.Bus;
namespace Things.Web.GoodsDescription
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                if (Request.Params["ID"] != null && Request.Params["ID"].Trim() != "")
                {
                    Guid productID = Guid.Empty;
                    Guid.TryParse(Request.Params["ID"], out productID);
                    if (productID != Guid.Empty)
                    {

                        btnGoCrops.Visible = true;
                    }
                }
                else
                {

                    btnGoCrops.Visible = false;
                }
            }
        }

        protected void btnSave_Click(object sender, EventArgs e)
        {

            string strErr = "";
            if (this.txtGoodsDescriptions.Text.Trim().Length == 0)
            {
                strErr += "GoodsDescriptions不能为空！\\n";
            }
            Guid goodsID = Guid.Empty;
            Guid.TryParse(Request.Params["ID"], out goodsID);
            if (goodsID == Guid.Empty)
            {
            }

            if (strErr != "")
            {
                MessageBox.Show(this, strErr);
                return;
            }
            string GoodsDescriptions = this.CKEditorControl1.Text;

            Things.Model.GoodsDescription model = new Things.Model.GoodsDescription();
            model.GoodsID = goodsID;
            model.GoodsDescriptions = GoodsDescriptions;

            Things.BLL.GoodsDescription bll = new Things.BLL.GoodsDescription();
            bll.Add(model);
            Things.Common.MessageBox.ShowAndRedirect(this, "保存成功！", "add.aspx");

        }


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }

        protected void btnGoCrops_Click(object sender, EventArgs e)
        {
            Response.Redirect("../Goods/list.aspx");
        }
    }
}
